blob: d02d6654e8213479a157fb640a622e557b3e8731 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
"use client";
import React, { useEffect, useState } from "react";
import { useRouter } from "next/router";
import "../../app/globals.css";
import TitleBar from "../../components/TitleBar/TitleBar";
import { ChannelCard } from "@/components/channel-card";
import DataChart from "@/components/DataChart/DataChart";
import axios from "axios";
interface ChannelDataProp {
channel_name: string;
profile_pic: string;
subscribers: number;
sub_org: string;
video_count: number;
next_milestone: string;
days_until_next_milestone: string;
next_milestone_date: string;
}
export default function Page() {
const [channelData, setChannelData] = useState<ChannelDataProp | null>(null);
const router = useRouter();
const { slug } = router.query;
useEffect(() => {
const apiUrl = process.env.NEXT_PUBLIC_API_URL;
if (slug) {
const encodedSlug = encodeURIComponent(slug as string);
console.log(apiUrl + `/api/channel/${encodedSlug}`);
axios.get(apiUrl + `/api/channel/${encodedSlug}`).then((response) => {
console.log(response);
setChannelData(response.data);
});
}
}, [slug]);
return (
<>
<TitleBar title={slug as string} redirectUrl="/" showHomeButton />
<div className="flex justify-center">
<div className="flex flex-col items-center">
{channelData && (
<ChannelCard
name={channelData.channel_name}
avatarUrl={channelData.profile_pic}
subscriberCount={channelData.subscribers}
videoCount={channelData.video_count}
suborg={channelData.sub_org}
nextMilestone={channelData.next_milestone}
nextMilestoneDays={channelData.days_until_next_milestone}
nextMilestoneDate={channelData.next_milestone_date}
/>
)}
</div>
</div>
<div className="px-48 mb-10 mt-10">
<div className="mb-12">
<DataChart channel_name={slug as string}/>
</div>
</div>
</>
);
}
|